/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */
#pragma once

#include "Key.h"
#include <vector>
#include <xml/Stream.h>

namespace liba
{
namespace animate
{

template<typename K>
class Keys : public xml::ObjectANSI, private std::vector< Key<K> >
{
	typedef std::vector< Key<K> > base_type;
public:
	using typename base_type::iterator;
	using typename base_type::const_iterator;
	using base_type::begin;
	using base_type::end;
	using base_type::size;
	using base_type::empty;
	using base_type::push_back;

	virtual bool on_node( xml::Provider * prov, const std::string & name )
	{
		if( name == "Key" )
		{
			push_back( Key<K>() );
			return prov->parse_object( &base_type::back() );
		}
		return false;
	}
};

template<typename K>
class KeysTCB : public xml::ObjectANSI, private std::vector< KeyTCB<K> >
{
	typedef std::vector< KeyTCB<K> > base_type;
public:
	using typename base_type::iterator;
	using typename base_type::const_iterator;
	using base_type::begin;
	using base_type::end;
	using base_type::size;
	using base_type::empty;
	using base_type::push_back;
	using base_type::operator [];

	virtual bool on_node( xml::Provider * prov, const std::string & name )
	{
		if( name == "Key" )
		{
			push_back( KeyTCB<K>() );
			return prov->parse_object( &base_type::back() );
		}
		return false;
	}
};

} // namespace animate
} // namespace liba
using namespace liba;
